/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entidade.persistencia;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author victorinox
 */
@Entity
@Table(name = "vinculo")
@NamedQueries({@NamedQuery(name = "Vinculo.findAll", query = "SELECT v FROM Vinculo v"), @NamedQuery(name = "Vinculo.findByVinculoId", query = "SELECT v FROM Vinculo v WHERE v.vinculoId = :vinculoId"), @NamedQuery(name = "Vinculo.findByNome", query = "SELECT v FROM Vinculo v WHERE v.nome = :nome")})
public class Vinculo implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "vinculo_id")
    private Integer vinculoId;
    @Basic(optional = false)
    @Column(name = "nome")
    private String nome;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "vinculoId", fetch = FetchType.LAZY)
    private List<TipoUsuario> tipoUsuarioCollection;

    public Vinculo() {
    }

    public Vinculo(Integer vinculoId) {
        this.vinculoId = vinculoId;
    }

    public Vinculo(Integer vinculoId, String nome) {
        this.vinculoId = vinculoId;
        this.nome = nome;
    }

    public Integer getVinculoId() {
        return vinculoId;
    }

    public void setVinculoId(Integer vinculoId) {
        this.vinculoId = vinculoId;
    }

    public String getNome() {
        return nome;
    }

    public void setNome(String nome) {
        this.nome = nome;
    }

    public List<TipoUsuario> getTipoUsuarioCollection() {
        return tipoUsuarioCollection;
    }

    public void setTipoUsuarioCollection(List<TipoUsuario> tipoUsuarioCollection) {
        this.tipoUsuarioCollection = tipoUsuarioCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (vinculoId != null ? vinculoId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Vinculo)) {
            return false;
        }
        Vinculo other = (Vinculo) object;
        if ((this.vinculoId == null && other.vinculoId != null) || (this.vinculoId != null && !this.vinculoId.equals(other.vinculoId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return getNome();
    }

}
